var QRCodeDlg = {
    QRCodeData:{}
};

QRCodeDlg.close = function () {
    parent.layer.close(window.parent.QRCode.layerIndex);
};

QRCodeDlg.clearData = function () {
    this.QRCodeData = {};
};

QRCodeDlg.set = function (key, value) {
    this.QRCodeData[key] = (typeof value == "undefined" || null == value) ? $("#" + key).val() : value;
    return this;
};

QRCodeDlg.get = function (key) {
    return $("#" + key).val();
};
QRCodeDlg.select = function (key) {
	return $("#"+key).find("option:selected").val();
};

QRCodeDlg.collectData = function () {
    this.set('codeType',QRCodeDlg.select("codeType")).set('num');
};

QRCodeDlg.provingNull = function () {
    if(this.select('codeType') && this.get('num')){
        return true;
    } else {
        return false;
    }
};

QRCodeDlg.addSubmitInfo = function () {
    this.clearData();
    
    this.collectData();

    if(!this.provingNull()){
    	Feng.error("请确认必填项");
        return;
    }
	//提交信息
    var ajax = new $ax(Feng.ctxPath + "/base/qrcode/add", function (data) {
        if(data.resultCode==1){
            Feng.success("添加成功!");
            window.parent.QRCode.table.refresh();
            parent.layer.close(window.parent.QRCode.layerIndex);
        }else{
            Feng.error(data.msg + "!");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    console.log(this.QRCodeData);
    ajax.set(this.QRCodeData);
    ajax.start();
    

    
}

QRCodeDlg.print = function(){
	
	var ids = $("#ids").val();
	this.set("ids",ids);
	//提交信息
    var ajax = new $ax(Feng.ctxPath + "/base/qrcode/print", function (data) {
        if(data.resultCode==1){
        	 /*bdhtml=window.document.body.innerHtml;  
            
            var headstr = "<html><head></head><body>";
            var footstr = "</body>";  
            var bodystr = document.all.item("row").innerHTML;                      
            var oldstr = document.body.innerHTML;  
                 
            document.body.innerHTML = headstr + bodystr + footstr;   */
           // pagesetup_null();      
            window.print();           
           // this.pagesetup_default();
            //document.body.innerHTML = oldstr;
            //return false;    
        }else{
            Feng.error(data.msg + "!");
        }
    }, function (data) {
        Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    console.log(this.QRCodeData);
    ajax.set(this.QRCodeData);
    ajax.start();
}
var hkey_root,hkey_path,hkey_key 
hkey_root="HKEY_CURRENT_USER" 
hkey_path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\" 
function pagesetup_null() 
{ 
	try{ 
        var RegWsh = new ActiveXObject("WScript.Shell") 
        hkey_key="header" 
        RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") 
        hkey_key="footer" 
        RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"") 
    }catch(e){} 

}
QRCodeDlg.pagesetup_default = function () 
{ 
	 try{ 
         var RegWsh = new ActiveXObject("WScript.Shell") 
         hkey_key="header" 
         RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码，&p/&P") 
         hkey_key="footer" 
         RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d") 
     }catch(e){} 

}





